/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package drt;

import java.util.Map;

/**
 *
 * @author phong
 */
public class DRSOrCondition extends DRSBinaryComplexCondition {
    
    public DRSOrCondition(DrtExpression first, DrtExpression second) {
        super(first, second);
    }
    
    @Override
    public DRSOrCondition simplify() {
        return new DRSOrCondition(this.first.simplify(), this.second.simplify());
    }
    
    @Override
    public DRSOrCondition replace(DrtVariable var, DrtExpression exp) {
        return new DRSOrCondition(
                first.replace(var, exp), 
                second.replace(var, exp));
    }
    
    @Override
    public String toString() {
        return "(" + this.first.toString() + ") | (" + this.second.toString() + ")";
    }
        
    @Override
    public boolean equals(Object other) {
        if (other instanceof DRSOrCondition) {
            DRSOrCondition that = (DRSOrCondition)other;
            return this.first.equals(that.first) && this.second.equals(that.second);
        }
        return false;
    }

    @Override
    public DRSOrCondition getTemplate(Map<String,String> map) {
        DrtExpression newFirst = this.first.getTemplate(map);
        DrtExpression newSecond = this.second.getTemplate(map);
        return new DRSOrCondition(newFirst, newSecond);
    }
}
